﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;


namespace ElingOA6_DSJCJ.BLL
{
    /// <summary>
    /// 业务逻辑类IPGroup 的摘要说明。
    /// </summary>
    public class IPGroup
    {

        /// <summary>
        /// Dal定义的便利
        /// </summary>
        private readonly DAL.IPGroup dal = new DAL.IPGroup();

        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <returns>List集合</returns>
        public List<Model.IPGroup> DataTableToListIPGroup(DataTable dt)
        {

            List<Model.IPGroup> modelList = new List<Model.IPGroup>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0) {
                Model.IPGroup model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.IPGroup();
                    if (dt.Rows[n]["FIPGroupID"] != null && dt.Rows[n]["FIPGroupID"].ToString() != "")
                    {
                        model.FIPGroupID = int.Parse(dt.Rows[n]["FIPGroupID"].ToString());
                    }
                    if (dt.Rows[n]["FEntityNo"] != null)
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    if (dt.Rows[n]["FStartIP"] != null && dt.Rows[n]["FStartIP"].ToString() != "")
                    {
                        model.FStartIP = long.Parse(dt.Rows[n]["FStartIP"].ToString());
                    }
                    if (dt.Rows[n]["FEndIP"] != null && dt.Rows[n]["FEndIP"].ToString() != "")
                    {
                        model.FEndIP = long.Parse(dt.Rows[n]["FEndIP"].ToString());
                    }
                    if (dt.Rows[n]["FIPGroupName"] != null)
                    {
                        model.FIPGroupName = dt.Rows[n]["FIPGroupName"].ToString();
                    }
                    modelList.Add(model);
                }
            }

            return modelList;
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="fIPGroupID">IPGroupID编号</param>
        /// <returns>得到一个对象实体</returns>
        public ElingOA6_DSJCJ.Model.IPGroup GetModel(int fIPGroupID)
        {
            return dal.GetModel(fIPGroupID);
        }
        /// <summary>
        /// 得到对象实体
        /// </summary>
        /// <param name="entity">公司编号</param>
        /// <returns>数据集合</returns>
        public List<ElingOA6_DSJCJ.Model.IPGroup> GetModelByEntity(string entity)
        {
            return DataTableToListIPGroup(dal.GetModelByEntity(entity).Tables[0]);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <param name="stratIP">开始IP字符串</param>
        /// <param name="endIP">结束IP字符串</param>
        /// <returns>添加记录</returns>
        public int Add(ElingOA6_DSJCJ.Model.IPGroup model, string stratIP, string endIP)
        {
            return dal.Add(model, stratIP, endIP);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model对象</param>
        /// <param name="stratIP">开始IP字符串</param>
        /// <param name="endIP">结束IP字符串</param>
        /// <returns>是否更新</returns>
        public bool Update(ElingOA6_DSJCJ.Model.IPGroup model, string stratIP, string endIP)
        {
            return dal.Update(model, stratIP, endIP);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="fIPGroupID">IPGroupID编号</param>
        /// <returns>是否删除</returns>
        public bool Delete(int fIPGroupID)
        {
            return dal.Delete(fIPGroupID);
        }

        /// <summary>
        /// 批量删除数据 
        /// <creator>chenly</creator>
        /// <date>2013-9-7</date>
        /// </summary>
        /// <param name="empNoArray">编号数组</param>
        /// <param name="entityNo">公司编号</param>
        public void DelMany(string[] groupIDArray, string entityNo)
        {
            dal.DelMany(groupIDArray, entityNo);
        }

    }
}
